from 第15天.func_decorator_to_class import print_attribute
from 第15天.method_decorator import print_input_param


class Person:
    def __init__(self, name: str, age: int, address: str):
        self.name = name
        self.age = age
        self.address = address

    def eat(self, food: str):
        print(f"{self.name}吃了{food}")


@print_attribute
class RealPerson(Person):
    pass


class RealMan(Person):
    @print_input_param
    def eat(self, food: str):
        return super().eat(food)


if __name__ == "__main__":
    init_param = ("白羽", 18, "杭州")
    food = "苹果"

    # # 1
    # print("1、调用装饰器的语法糖")
    # baiyu_1 = RealPerson(*init_param)
    #
    # # 2
    # print("2、调用装饰器函数本身")
    # baiyu_2 = print_attribute(Person)(*init_param)
    #
    # # 3
    # print("3、拆分调用装饰器函数的步骤")
    # baiyu_3_step_1 = print_attribute(Person)
    # baiyu_3 = baiyu_3_step_1(*init_param)

    # 4
    print("4、调用装饰器的语法糖")
    baiyu_4 = RealMan(*init_param)
    baiyu_4.eat(food)

    # 5
    print("5、调用装饰器函数本身")
    baiyu_5 = RealMan(*init_param)
    print_input_param(RealMan.eat)(baiyu_5, food)

    # 6
    print("6、拆分调用装饰器函数的步骤")
    baiyu_6 = RealMan(*init_param)
    baiyu_6_step_1 = print_input_param(RealMan.eat)
    baiyu_6_step_1(baiyu_5, food)

